﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using QMERP.Domain.Entities;

namespace QMERP.Infrastructure.EFCore.Mappings
{
    public class AttachmentMapping : IEntityTypeConfiguration<Attachment>
    {
        public void Configure(EntityTypeBuilder<Attachment> builder)
        {
            builder.Property(x => x.OwnerId).IsRequired(false);
            builder.Property(x => x.OwnerType).HasMaxLength(50);
            builder.Property(x => x.FileName).HasMaxLength(200);
            builder.Property(x => x.FileSize);
            builder.Property(x => x.FileExtend).HasMaxLength(10);
            builder.Property(x => x.BasePath).IsRequired(false).HasMaxLength(1000);
            builder.Property(x => x.SavePath).IsRequired(false).HasMaxLength(1000);

            builder.HasIndex(x => x.Id);
            builder.HasIndex(x => x.OwnerId);
            builder.HasIndex(x => x.OwnerType);
        }
    }
}
